<!--
  * 仓库下拉选择框
-->
<template>
  <a-select :options="list" />
</template>

<script setup lang="ts">
import { searchApi } from '@/api/search/search-api'
import { useEnums } from '@/hooks/plugins/useEnums'
const { getDescByValue } = useEnums()
// =========== 查询数据 =============
const props = defineProps({
  fetchParams: {
    type: Object,
    default: () => ({})
  }
})
const list = shallowRef([])
async function queryList(fetchParams?: any) {
  const params = fetchParams ?? props.fetchParams
  const res = await searchApi.warehouseList(params)
  list.value = res.data.map((item) => {
    return {
      ...item,
      label: `${getDescByValue('WAREHOUSE_ATTRIBUTE_TYPE', item.attribute_type)} - ${item.name}`,
      value: item.id
    }
  })
}
onMounted(queryList)
defineExpose({
  queryList
})
</script>
